package com.ars.common.servlet.admin.material;

import com.ars.common.beans.Active.Active;
import com.ars.common.beans.User.User;
import com.ars.common.dao.activity.FindClassActive;
import com.ars.common.dao.activity.FindCollegeActive;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.sql.SQLException;
import java.util.ArrayList;

/*
 * @Author: liWentao
 * @Date: 2024/8/28 20:20
 * 根据登录的用户ID进行查找院级活动
 * */

@WebServlet("/CollegeMaterial")
public class CollegeMaterial extends HttpServlet {
    public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
    {
        User logUser = (User) request.getSession().getAttribute("LogUser");
        String logId = logUser.getUserID();
        String Class = logId.substring(4,5);

        ArrayList<Active> active = new ArrayList<>();

        //在数据库中查找班级活动
        try {
            active = new FindCollegeActive().findActive(Class);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

        request.setAttribute("active", active);
        request.getRequestDispatcher("admin/CollegeMaterial.jsp").forward(request, response);

    }
}
